package com.niuxiaofa.newlaw.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.niuxiaofa.newlaw.Bean.BannerBean;
import com.niuxiaofa.newlaw.Tools.GlideUtils;
import com.niuxiaofa.newlaw.Tools.UIUtils;
import com.to.aboomy.banner.HolderCreator;

/**
 * @ClassName ImageHolderCreator
 * @Description TODO
 * @Author Gxjkz
 * @Date 2020/8/24 15:40
 * @Version 1.0
 */
//举个栗子
public class BannerCreator implements HolderCreator {


    Onclick onclick;

    public BannerCreator(Onclick onclick){
       this.onclick=onclick;
    }

    @Override
    public View createView(final Context context, final int index, Object o) {
        ImageView iv = new ImageView(context);

        BannerBean.DataDTO bannerBean=(BannerBean.DataDTO)o;

        iv.setScaleType(ImageView.ScaleType.CENTER_CROP);


        GlideUtils.loadRoundedImage(UIUtils.getContext(),bannerBean.getBannerUrl(),iv);

        //内部实现点击事件
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onclick.click(index);
            }
        });
        return iv;
    }


   public interface Onclick{
       void click(int id);
   }
}
